package com.five.years.common.utils;

import java.math.BigDecimal;

public class DistanceUtil {

    public static BigDecimal calculateDistance(Double myLatitude, Double latitude, Double myLongitude, Double longitude){
        long round = Math.round(6378.138 * 2 * Math.asin(Math.sqrt(Math.pow(Math.sin((myLatitude - latitude)
                * Math.PI / 360), 2) + Math.cos(myLatitude * Math.PI / 180) * Math.cos(latitude * Math.PI / 180)
                * Math.pow(Math.sin((myLongitude - longitude) * Math.PI / 360), 2))));
        return BigDecimal.valueOf(round);
    }
}
